import sys

from PyQt5.QtWidgets import *
from PyQt5.QtGui import *
from PyQt5.QtCore import *

class ShowTime(QWidget):
    def __init__(self):
        super().__init__()

        self.setWindowTitle("多线程使用 Times")
        self.label = QLabel("time")
        self.sBtn = QPushButton('开始')
        self.enBtn = QPushButton('结束')

        layout = QGridLayout()

        self.timer = QTimer()
        self.timer.timeout.connect(self.showTime)

        layout.addWidget(self.label, 0, 0, 1, 2)
        layout.addWidget(self.sBtn, 1, 0)
        layout.addWidget(self.enBtn, 1, 1)

        self.sBtn.clicked.connect(self.startTime)
        self.enBtn.clicked.connect(self.endTime)
        self.setLayout(layout)

    def showTime(self):

        time = QDateTime.currentDateTime()

        timeDisplay = time.toString('yyyy-MM-dd hh:mm:ss dddd')
        self.label.setText(timeDisplay)


    def startTime(self):

        self.timer.start(1000)#ms
        self.sBtn.setEnabled(False)
        self.enBtn.setEnabled(True)

    def endTime(self):

        self.timer.stop()
        self.sBtn.setEnabled(True)
        self.enBtn.setEnabled(False)

if __name__ == '__main__':

    app = QApplication(sys.argv)
    ex = ShowTime()
    ex.show()
    sys.exit(app.exec_())